package com.ssm.card.dao.mapper.building;

import com.github.pagehelper.PageInfo;
import com.jee.ssm.common.web.param.ParamMap;
import com.ssm.card.dao.model.building.Building;
import com.ssm.upms.dao.mapper.ssm.LzDao;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
* 楼栋管理 Dao
* @author GaoXiang
* @version 1.0
*/
@Repository
public class BuildingDao extends LzDao<Building> {



    /**
    * 保存数据
    * @param building 实体对象
    * @return 实体id
    * @throws Exception 数据保存异常
    */
    public Integer insert(Building building) throws Exception {
        return insert("BuildingMapper.insert",building);
    }

    /**
    * 根据 id 修改
    * @param building 带id的实体对象
    * @return 受影响的行数
    * @throws Exception 数据修改异常
    */
    public Integer updateById(Building building) throws Exception {
        return update("BuildingMapper.updateById",building);
    }

    /**
    * 根据 id 删除
    * @param id 数据id
    * @return 受影响的行数
    * @throws Exception 数据删除异常
    */
    public Integer deleteById(String id) throws Exception {
        return delete("BuildingMapper.deleteById",id);
    }

    /**
    * 根据 id 查找
    * @param id 实体id
    * @return 实体
    */
    public Building selectById(String id) {
        return selectOne("BuildingMapper.selectById",id);
    }

    /**
    * 根据 id 批量删除
    * @param ids 要删除的id
    * @return 影响的行数
    * @throws Exception 数据删除异常
    */
    public Integer deleteByIds(List<String> ids) throws Exception {
        return delete("BuildingMapper.deleteByIds",ids);
    }

    /**
    * 查询列表
    * @param map 参数
    * @return 列表
    */
    public PageInfo<Building> list(Map map) {
        return list("BuildingMapper.list",map);
    }

    /**
    * 查询列表 带分页
    * @param map 参数
    * @param page 页码
    * @param size 每页大小
    * @return 列表
    */
    public PageInfo<Building> list(Map map, int page, int size) {
        return list("BuildingMapper.list",map,new RowBounds(page,size));
    }


    public List<Building> chooseList(String residenceId){
        return  arrayList("BuildingMapper.chooseList",residenceId);
    }

    public  Long count(Map map){return count("BuildingMapper.count",map);}
    /**
     *  根据小区查询楼栋id
     * @param residenceId 参数 小区id
     * @return 列表
     */
    public List<Building> findByResidenceId(String residenceId) {
        return arrayList("BuildingMapper.findByResidenceId", residenceId);
    }



    /**
     *  统计有楼栋的小区名字
     * @param building 参数
     * @return 列表
     */
    public List<Building> countName(Building building) {
        return arrayList("BuildingMapper.countName", building);
    }
    /**
     *  统计小区楼栋数量
     * @param building 参数
     * @return 列表
     */
    public Building countNumber(Building building) {
        return selectOne("BuildingMapper.countNumber", building);
    }
    /**
     *  统计统计楼栋建设时间-
     * @param building 参数
     * @return 列表
     */
    public List<Building> countName2(Building building) {
        return arrayList("BuildingMapper.countName2", building);
    }
    /**
     *  统计楼栋建设时间各段时间数量
     * @param building 参数
     * @return 列表
     */
    public Building countNumber2(Building building) {
        return selectOne("BuildingMapper.countNumber2", building);
    }
    /**
     *  根据小区选择楼栋
     * @param residenceId 参数 小区id
     * @return 列表
     */
    public List<Building> chooseBuilding(String residenceId){ return  arrayList("BuildingMapper.chooseBuilding",residenceId);}


    public List<Building> listWithoutPage(ParamMap paramMap) {
        return arrayList("BuildingMapper.listWithoutPage", paramMap);
    }

    /**
     * 查询列表，不带分页
     * @param map 参数
     * @return 列表
     */
    public List<Building> listAll(Map map){return  arrayList("BuildingMapper.listAll",map);}

    public Integer deleteByResidenceId(String id) throws Exception {
        return delete("BuildingMapper.deleteByResidenceId",id);
    }

    /**
     * 根据楼栋的编号查询
     * @param map 参数
     * @return 实体
     */
    public Building selectBybuilNumber(Map map){return selectOne("BuildingMapper.selectBybuilNumber",map);}


    /**
     * 男
     * @param paramMap
     * @return
     */
    public Long  countMale(ParamMap paramMap){
        return count("BuildingMapper.countMale",paramMap);
    }
    /**
     * 女
     * @param paramMap
     * @return
     */
    public Long  countFemale(ParamMap paramMap){
        return count("BuildingMapper.countFemale",paramMap);
    }
    /**
     * 老
     * @param paramMap
     * @return
     */
    public Long  countOld(ParamMap paramMap){
        return count("BuildingMapper.countOld",paramMap);
    }

    /**
     * 幼
     * @param paramMap
     * @return
     */
    public Long  countChild(ParamMap paramMap){
        return count("BuildingMapper.countChild",paramMap);
    }
    /**
     * 楼栋
     * @param paramMap
     * @return
     */
    public Long  countBuild(ParamMap paramMap){
        return count("BuildingMapper.countBuild",paramMap);
    }

    /**
     * 单元
     * @param paramMap
     * @return
     */
    public Long  countUnit(ParamMap paramMap){
        return count("BuildingMapper.countUnit",paramMap);
    }
    /**
     * 房间
     * @param paramMap
     * @return
     */
    public Long  countRoom(ParamMap paramMap){
        return count("BuildingMapper.countRoom",paramMap);
    }
    /**
     * 特殊人群总人数
     * @param paramMap
     * @return
     */
    public Long sensitiveCount(ParamMap paramMap){
        return count("BuildingMapper.sensitiveCount",paramMap);
    }

    /**
     * 涉恐人员人数
     * @param paramMap
     * @return
     */
    public Long  terrorismCount(ParamMap paramMap){
        return count("BuildingMapper.terrorismCount",paramMap);
    }

    /**
     * 涉稳人员人数
     * @param paramMap
     * @return
     */
    public Long  stabilityCount(ParamMap paramMap){
        return count("BuildingMapper.stabilityCount",paramMap);
    }

    /**
     * 重大刑事犯罪前科人员人数
     * @param paramMap
     * @return
     */
    public Long  criminalCount(ParamMap paramMap){
        return count("BuildingMapper.criminalCount",paramMap);
    }

    /**
     * 涉毒人数
     * @param paramMap
     * @return
     */
    public Long  drugsCount(ParamMap paramMap){
        return count("BuildingMapper.drugsCount",paramMap);
    }

    /**
     * 肇事肇祸精神病人人数
     * @param paramMap
     * @return
     */
    public Long  psychosisCount(ParamMap paramMap){
        return count("BuildingMapper.psychosisCount",paramMap);
    }

    /**
     * 重点上访人员人数
     * @param paramMap
     * @return
     */
    public Long  petitionCount(ParamMap paramMap){
        return count("BuildingMapper.petitionCount",paramMap);
    }



}
